<!doctype html>
<html>
<!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>添加投诉</title>
<!-- InstanceEndEditable -->

<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script> 
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.pager.js"></script>
<script type="text/javascript" src="../js/gbRst.js"></script>
<script type="text/javascript" src="../js/doubleDate2.0.js"></script>
	<script type="text/javascript" src="../js/utils.js"></script>
	<link href="../css/style.css" type="text/css" rel="stylesheet" />

<script type="text/javascript">
var _complaintId= 0;
var _cusId;
$(function(){
	$("#isMember").change(function(){
	
		var isMember= $("#isMember").val();
		if(isMember==0){
		$("#searchM").show();
		}
	});
	restForm();
})

function getComplainById(){
	
	$.ajax({
		type : "get",
		async:false,
		datatype : "json",
		url : "../complnt/find/complaintById/id/"+_complaintId,
		success : function(data) {
			var rst = JSON.parse(data);
			 if(IsEmpty(rst)){
					art.dialog({fixed:true, lock: true,content:"查询出错",icon:'error',ok:true});	
					return false;
					}
					if(rst.state==0){
						restForm();
					if(rst.result.len==0){
						art.dialog({fixed:true, lock: true,content:"该条数据不存在",icon:'error',ok:true});	
						return false;	
					}else if(rst.state==1){
						art.dialog({fixed:true, lock: true,content:rst.msg,icon:'error',ok:true});	
					}else{
						checkStateShowErrorMsgAndDealResult(data);
					}
		}
		}
	});
}

function toSaveS(){ 
	
	/* var isMember = $("#isMember").val();
	if(isMember==0){
		if(IsEmpty(_cusId)){
			art.dialog({fixed:true, lock: true,content:"该会员不存在",icon:'error',ok:true});
			return false;		

		}
	} */
	var custName=$("#custName").val();
	var phone = $("#phone").val();
	var title = $("#title").val();
	var content = $("#content").val();
	var cmpltTypeName = $("#cmpltTypeName").val();
	if(IsEmpty(custName)){
		art.dialog({fixed:true, lock: true,content:"姓名不能为空",icon:'error',ok:true});
		$("#custName").focus();
		return false;		
	}
	if(IsEmpty(phone)){
		art.dialog({fixed:true, lock: true,content:"联系方式不能为空",icon:'error',ok:true});
		$("#phone").focus();
		return false;		
	}
	if(IsEmpty(title)){
		art.dialog({fixed:true, lock: true,content:"主题不能为空",icon:'error',ok:true});
		$("#title").focus();
		return false;		
	}
	if(IsEmpty(content)){
		art.dialog({fixed:true, lock: true,content:"内容不能为空",icon:'error',ok:true});
		$("#content").focus();
		return false;		
	}
	
	
	
	var heads=new Array("custName","phone","title","content","shopId","cmpltTypeName");
	var datas=new Array(custName,phone,title,content,"0",cmpltTypeName);
	var parser = new Object();
	var jsonParserStr = null;
	if (IsNotEmpty(datas)){
		addToParser(heads, datas, "add" , parser);
		jsonParserStr =  JSON.stringify(parser);
	}
	
	$.post("../complnt/insert/insertInfo",{"data":jsonParserStr}, function(data) {
		var dt = JSON.parse(data);	
				 if(IsEmpty(dt)){
				art.dialog({fixed:true, lock: true,content:"添加出错",icon:'error',ok:true});	
				return false;
				}
				if(dt.state==0){
				art.dialog({fixed:true, lock: true,content:"添加成功",icon:'succeed',ok:true});
				restForm();
				}else if(dt.state==1){
					art.dialog({fixed:true, lock: true,content:dt.msg,icon:'error',ok:true});
				}else{
					checkStateShowErrorMsgAndDealResult(data);
				}
		
	});
}

function returnURL(){
	window.location.href='complain.html?cusName='+getIdByName("cusName")+"&flag=2&dtBegin="+getIdByName("dtBegin")+"&dtEnd="+getIdByName("dtEnd")+"&status="+getIdByName("status")+"&pageIndex="+getIdByName("pageIndex")
}

function restForm(){
	$("#isMember").val(1);
	$("#custName").val("");
	$("#phone").val("");
	$("#title").val("");
	$("#content").val("");
	$("#searchM").hide();
	
}
</script>


</head>

<body>
<!-- InstanceBeginEditable name="EditRegion3" --> 


<div class="container" id="container">
  <div class="container_R fr">
      <div class="place"><a onclick='returnURL()' href='javaScript:void(0)'>投诉建议</a><span> &gt; <span>添加<a class="goHome" onclick='returnURL()' href='javaScript:void(0)'>返回</a></div>
    <div class="member_search publish"  style="padding:0;">
    <div class="knowPerson">
      <p class="knowAll">
        <label> <span>类型：</span>
         <select id="cmpltTypeName">
         <option value="投诉">投诉</option>
         <option value="建议">建议</option>
         </select>
        </label>
        
        </p>
     <!--  <p class="knowAll">
        <label> <span>是否为会员：</span>
         <select id="isMember">
         <option value="0">是</option>
         <option value="1">否</option>
         </select>
        </label>
         <label id="voiceShow" style="display: none;"> <span> </span>
        <a >

    <font style="text-decoration:underline; color: green;">选择会员</font>

</a>
        </label>
        </p> -->
      <p class="knowAll" id="mInfo">
        <label> <span>姓名或昵称：</span>
          <input type="text"  id="custName">
        </label>
        <label> <span>联系方式：</span>
          <input type="text"  id="phone">
        </label>
        <label id="searchM" style="display: none;">
         <span><a onclick="getComplainById()" href="javascript:void(0)">查询</a></span>
        </label>
        </p>
      </div>
  
      	<p>
      	
      	<div class="knowPerson">
      <p class="knowAll">
        <label> <span>主题：</span>
          <input type="text"  id="title" style="width: 200px;">
        </label>
     
        </p>
        <p class="knowAll">
        <label> <span>内容：</span>
          <textarea   id="content" style="width: 400px;height: 50px;"></textarea>
        </label>
       
        </p>
      </div>
      <p> 
        <div class="BottomBtn">
            <input id="cl_btn" type="button" value="提交" onclick="toSaveS()">      
            </div>
       </div>  
  </div>
    <div class="fc"></div>
  
</div>
<!-- InstanceEndEditable --> 
<script type="text/javascript" src="../js/header.js"></script> 
<script type="text/javascript" src="../js/left.js"></script> 
<script type="text/javascript" src="../js/footer.js"></script> 
<script type="text/javascript">
clearThis("absoluteTxt");
showTab(4, 9);
</script>
</body>
<!-- InstanceEnd -->
</html>
